

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="Description" content="scikit-learn: machine learning in Python">

  
  <title>sklearn.gaussian_process.GaussianProcessRegressor &mdash; scikit-learn 0.22 documentation</title>
  
  <link rel="canonical" href="http://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.GaussianProcessRegressor.html" />

  
  <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  <link rel="stylesheet" href="../../_static/css/vendor/bootstrap.min.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script> 
</head>
<body>
<nav id="navbar" class="sk-docs-navbar navbar navbar-expand-md navbar-light bg-light py-0">
  <div class="container-fluid sk-docs-container px-0">
      <a class="navbar-brand py-0" href="../../index.html">
        <img
          class="sk-brand-img"
          src="../../_static/scikit-learn-logo-small.png"
          alt="logo"/>
      </a>
    <button
      id="sk-navbar-toggler"
      class="navbar-toggler"
      type="button"
      data-toggle="collapse"
      data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent"
      aria-expanded="false"
      aria-label="Toggle navigation"
    >
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="sk-navbar-collapse collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../../install.html">Install</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../../user_guide.html">User Guide</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../classes.html">API</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../../auto_examples/index.html">Examples</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../getting_started.html">Getting Started</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../tutorial/index.html">Tutorial</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../glossary.html">Glossary</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../developers/index.html">Development</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../faq.html">FAQ</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../related_projects.html">Related packages</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../roadmap.html">Roadmap</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../about.html">About us</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
        </li>
        <li class="nav-item dropdown nav-more-item-dropdown">
          <a class="sk-nav-link nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">More</a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdown">
              <a class="sk-nav-dropdown-item dropdown-item" href="../../getting_started.html">Getting Started</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../tutorial/index.html">Tutorial</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../glossary.html">Glossary</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../developers/index.html">Development</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../faq.html">FAQ</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../related_projects.html">Related packages</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../roadmap.html">Roadmap</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../about.html">About us</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
          </div>
        </li>
      </ul>
      <div id="searchbox" role="search">
          <div class="searchformwrapper">
          <form class="search" action="../../search.html" method="get">
            <input class="sk-search-text-input" type="text" name="q" aria-labelledby="searchlabel" />
            <input class="sk-search-text-btn" type="submit" value="Go" />
          </form>
          </div>
      </div>
    </div>
  </div>
</nav>
<div class="d-flex" id="sk-doc-wrapper">
    <input type="checkbox" name="sk-toggle-checkbox" id="sk-toggle-checkbox">
    <label id="sk-sidemenu-toggle" class="sk-btn-toggle-toc btn sk-btn-primary" for="sk-toggle-checkbox">Toggle Menu</label>
    <div id="sk-sidebar-wrapper" class="border-right">
      <div class="sk-sidebar-toc-wrapper">
        <div class="sk-sidebar-toc-logo">
          <a href="../../index.html">
            <img
              class="sk-brand-img"
              src="../../_static/scikit-learn-logo-small.png"
              alt="logo"/>
          </a>
        </div>
        <div class="btn-group w-100 mb-2" role="group" aria-label="rellinks">
            <a href="sklearn.gaussian_process.GaussianProcessClassifier.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="sklearn.gaussian_process.GaussianProcessClassifier">Prev</a><a href="../classes.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="API Reference">Up</a>
            <a href="sklearn.gaussian_process.kernels.CompoundKernel.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="sklearn.gaussian_process.kernels.CompoundKernel">Next</a>
        </div>
        <div class="alert alert-danger p-1 mb-2" role="alert">
          <p class="text-center mb-0">
          <strong>scikit-learn 0.22</strong><br/>
          <a href="http://scikit-learn.org/dev/versions.html">Other versions</a>
          </p>
        </div>
        <div class="alert alert-warning p-1 mb-2" role="alert">
          <p class="text-center mb-0">
            Please <a class="font-weight-bold" href="../../about.html#citing-scikit-learn"><string>cite us</string></a> if you use the software.
          </p>
        </div>
          <div class="sk-sidebar-toc">
            <ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sklearn.gaussian_process</span></code>.GaussianProcessRegressor</a><ul>
<li><a class="reference internal" href="#examples-using-sklearn-gaussian-process-gaussianprocessregressor">Examples using <code class="docutils literal notranslate"><span class="pre">sklearn.gaussian_process.GaussianProcessRegressor</span></code></a></li>
</ul>
</li>
</ul>

          </div>
      </div>
    </div>
    <div id="sk-page-content-wrapper">
      <div class="sk-page-content container-fluid body px-md-3" role="main">
        
  <div class="section" id="sklearn-gaussian-process-gaussianprocessregressor">
<h1><a class="reference internal" href="../classes.html#module-sklearn.gaussian_process" title="sklearn.gaussian_process"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sklearn.gaussian_process</span></code></a>.GaussianProcessRegressor<a class="headerlink" href="#sklearn-gaussian-process-gaussianprocessregressor" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor">
<em class="property">class </em><code class="sig-prename descclassname">sklearn.gaussian_process.</code><code class="sig-name descname">GaussianProcessRegressor</code><span class="sig-paren">(</span><em class="sig-param">kernel=None</em>, <em class="sig-param">alpha=1e-10</em>, <em class="sig-param">optimizer='fmin_l_bfgs_b'</em>, <em class="sig-param">n_restarts_optimizer=0</em>, <em class="sig-param">normalize_y=False</em>, <em class="sig-param">copy_X_train=True</em>, <em class="sig-param">random_state=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/gaussian_process/_gpr.py#L22"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor" title="Permalink to this definition">¶</a></dt>
<dd><p>Gaussian process regression (GPR).</p>
<p>The implementation is based on Algorithm 2.1 of Gaussian Processes
for Machine Learning (GPML) by Rasmussen and Williams.</p>
<p>In addition to standard scikit-learn estimator API,
GaussianProcessRegressor:</p>
<blockquote>
<div><ul class="simple">
<li><p>allows prediction without prior fitting (based on the GP prior)</p></li>
<li><p>provides an additional method sample_y(X), which evaluates samples
drawn from the GPR (prior or posterior) at given inputs</p></li>
<li><p>exposes a method log_marginal_likelihood(theta), which can be used
externally for other ways of selecting hyperparameters, e.g., via
Markov chain Monte Carlo.</p></li>
</ul>
</div></blockquote>
<p>Read more in the <a class="reference internal" href="../gaussian_process.html#gaussian-process"><span class="std std-ref">User Guide</span></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">New in version 0.18.</span></p>
</div>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>kernel</strong><span class="classifier">kernel object</span></dt><dd><p>The kernel specifying the covariance function of the GP. If None is
passed, the kernel “1.0 * RBF(1.0)” is used as default. Note that
the kernel’s hyperparameters are optimized during fitting.</p>
</dd>
<dt><strong>alpha</strong><span class="classifier">float or array-like, optional (default: 1e-10)</span></dt><dd><p>Value added to the diagonal of the kernel matrix during fitting.
Larger values correspond to increased noise level in the observations.
This can also prevent a potential numerical issue during fitting, by
ensuring that the calculated values form a positive definite matrix.
If an array is passed, it must have the same number of entries as the
data used for fitting and is used as datapoint-dependent noise level.
Note that this is equivalent to adding a WhiteKernel with c=alpha.
Allowing to specify the noise level directly as a parameter is mainly
for convenience and for consistency with Ridge.</p>
</dd>
<dt><strong>optimizer</strong><span class="classifier">string or callable, optional (default: “fmin_l_bfgs_b”)</span></dt><dd><p>Can either be one of the internally supported optimizers for optimizing
the kernel’s parameters, specified by a string, or an externally
defined optimizer passed as a callable. If a callable is passed, it
must have the signature:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">optimizer</span><span class="p">(</span><span class="n">obj_func</span><span class="p">,</span> <span class="n">initial_theta</span><span class="p">,</span> <span class="n">bounds</span><span class="p">):</span>
    <span class="c1"># * &#39;obj_func&#39; is the objective function to be minimized, which</span>
    <span class="c1">#   takes the hyperparameters theta as parameter and an</span>
    <span class="c1">#   optional flag eval_gradient, which determines if the</span>
    <span class="c1">#   gradient is returned additionally to the function value</span>
    <span class="c1"># * &#39;initial_theta&#39;: the initial value for theta, which can be</span>
    <span class="c1">#   used by local optimizers</span>
    <span class="c1"># * &#39;bounds&#39;: the bounds on the values of theta</span>
    <span class="o">....</span>
    <span class="c1"># Returned are the best found hyperparameters theta and</span>
    <span class="c1"># the corresponding value of the target function.</span>
    <span class="k">return</span> <span class="n">theta_opt</span><span class="p">,</span> <span class="n">func_min</span>
</pre></div>
</div>
<p>Per default, the ‘L-BGFS-B’ algorithm from scipy.optimize.minimize
is used. If None is passed, the kernel’s parameters are kept fixed.
Available internal optimizers are:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;fmin_l_bfgs_b&#39;</span>
</pre></div>
</div>
</dd>
<dt><strong>n_restarts_optimizer</strong><span class="classifier">int, optional (default: 0)</span></dt><dd><p>The number of restarts of the optimizer for finding the kernel’s
parameters which maximize the log-marginal likelihood. The first run
of the optimizer is performed from the kernel’s initial parameters,
the remaining ones (if any) from thetas sampled log-uniform randomly
from the space of allowed theta-values. If greater than 0, all bounds
must be finite. Note that n_restarts_optimizer == 0 implies that one
run is performed.</p>
</dd>
<dt><strong>normalize_y</strong><span class="classifier">boolean, optional (default: False)</span></dt><dd><p>Whether the target values y are normalized, i.e., the mean of the
observed target values become zero. This parameter should be set to
True if the target values’ mean is expected to differ considerable from
zero. When enabled, the normalization effectively modifies the GP’s
prior based on the data, which contradicts the likelihood principle;
normalization is thus disabled per default.</p>
</dd>
<dt><strong>copy_X_train</strong><span class="classifier">bool, optional (default: True)</span></dt><dd><p>If True, a persistent copy of the training data is stored in the
object. Otherwise, just a reference to the training data is stored,
which might cause predictions to change if the data is modified
externally.</p>
</dd>
<dt><strong>random_state</strong><span class="classifier">int, RandomState instance or None, optional (default: None)</span></dt><dd><p>The generator used to initialize the centers. If int, random_state is
the seed used by the random number generator; If RandomState instance,
random_state is the random number generator; If None, the random number
generator is the RandomState instance used by <code class="docutils literal notranslate"><span class="pre">np.random</span></code>.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Attributes</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>X_train_</strong><span class="classifier">sequence of length n_samples</span></dt><dd><p>Feature vectors or other representations of training data (also
required for prediction). Could either be array-like with shape =
(n_samples, n_features) or a list of objects.</p>
</dd>
<dt><strong>y_train_</strong><span class="classifier">array-like of shape (n_samples,) or (n_samples, n_targets)</span></dt><dd><p>Target values in training data (also required for prediction)</p>
</dd>
<dt><strong>kernel_</strong><span class="classifier">kernel object</span></dt><dd><p>The kernel used for prediction. The structure of the kernel is the
same as the one passed as parameter but with optimized hyperparameters</p>
</dd>
<dt><strong>L_</strong><span class="classifier">array-like of shape (n_samples, n_samples)</span></dt><dd><p>Lower-triangular Cholesky decomposition of the kernel in <code class="docutils literal notranslate"><span class="pre">X_train_</span></code></p>
</dd>
<dt><strong>alpha_</strong><span class="classifier">array-like of shape (n_samples,)</span></dt><dd><p>Dual coefficients of training data points in kernel space</p>
</dd>
<dt><strong>log_marginal_likelihood_value_</strong><span class="classifier">float</span></dt><dd><p>The log-marginal-likelihood of <code class="docutils literal notranslate"><span class="pre">self.kernel_.theta</span></code></p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sklearn.datasets</span> <span class="kn">import</span> <span class="n">make_friedman2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sklearn.gaussian_process</span> <span class="kn">import</span> <span class="n">GaussianProcessRegressor</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sklearn.gaussian_process.kernels</span> <span class="kn">import</span> <span class="n">DotProduct</span><span class="p">,</span> <span class="n">WhiteKernel</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">X</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">make_friedman2</span><span class="p">(</span><span class="n">n_samples</span><span class="o">=</span><span class="mi">500</span><span class="p">,</span> <span class="n">noise</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">random_state</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">kernel</span> <span class="o">=</span> <span class="n">DotProduct</span><span class="p">()</span> <span class="o">+</span> <span class="n">WhiteKernel</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gpr</span> <span class="o">=</span> <span class="n">GaussianProcessRegressor</span><span class="p">(</span><span class="n">kernel</span><span class="o">=</span><span class="n">kernel</span><span class="p">,</span>
<span class="gp">... </span>        <span class="n">random_state</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gpr</span><span class="o">.</span><span class="n">score</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">0.3680...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gpr</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">X</span><span class="p">[:</span><span class="mi">2</span><span class="p">,:],</span> <span class="n">return_std</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(array([653.0..., 592.1...]), array([316.6..., 316.6...]))</span>
</pre></div>
</div>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#sklearn.gaussian_process.GaussianProcessRegressor.fit" title="sklearn.gaussian_process.GaussianProcessRegressor.fit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fit</span></code></a>(self, X, y)</p></td>
<td><p>Fit Gaussian process regression model.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#sklearn.gaussian_process.GaussianProcessRegressor.get_params" title="sklearn.gaussian_process.GaussianProcessRegressor.get_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_params</span></code></a>(self[, deep])</p></td>
<td><p>Get parameters for this estimator.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#sklearn.gaussian_process.GaussianProcessRegressor.log_marginal_likelihood" title="sklearn.gaussian_process.GaussianProcessRegressor.log_marginal_likelihood"><code class="xref py py-obj docutils literal notranslate"><span class="pre">log_marginal_likelihood</span></code></a>(self[, theta, …])</p></td>
<td><p>Returns log-marginal likelihood of theta for training data.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#sklearn.gaussian_process.GaussianProcessRegressor.predict" title="sklearn.gaussian_process.GaussianProcessRegressor.predict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">predict</span></code></a>(self, X[, return_std, return_cov])</p></td>
<td><p>Predict using the Gaussian process regression model</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#sklearn.gaussian_process.GaussianProcessRegressor.sample_y" title="sklearn.gaussian_process.GaussianProcessRegressor.sample_y"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sample_y</span></code></a>(self, X[, n_samples, random_state])</p></td>
<td><p>Draw samples from Gaussian process and evaluate at X.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#sklearn.gaussian_process.GaussianProcessRegressor.score" title="sklearn.gaussian_process.GaussianProcessRegressor.score"><code class="xref py py-obj docutils literal notranslate"><span class="pre">score</span></code></a>(self, X, y[, sample_weight])</p></td>
<td><p>Return the coefficient of determination R^2 of the prediction.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#sklearn.gaussian_process.GaussianProcessRegressor.set_params" title="sklearn.gaussian_process.GaussianProcessRegressor.set_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_params</span></code></a>(self, \*\*params)</p></td>
<td><p>Set the parameters of this estimator.</p></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.__init__">
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">kernel=None</em>, <em class="sig-param">alpha=1e-10</em>, <em class="sig-param">optimizer='fmin_l_bfgs_b'</em>, <em class="sig-param">n_restarts_optimizer=0</em>, <em class="sig-param">normalize_y=False</em>, <em class="sig-param">copy_X_train=True</em>, <em class="sig-param">random_state=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/gaussian_process/_gpr.py#L153"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self.  See help(type(self)) for accurate signature.</p>
</dd></dl>

<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.fit">
<code class="sig-name descname">fit</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em>, <em class="sig-param">y</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/gaussian_process/_gpr.py#L164"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.fit" title="Permalink to this definition">¶</a></dt>
<dd><p>Fit Gaussian process regression model.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">sequence of length n_samples</span></dt><dd><p>Feature vectors or other representations of training data.
Could either be array-like with shape = (n_samples, n_features)
or a list of objects.</p>
</dd>
<dt><strong>y</strong><span class="classifier">array-like of shape (n_samples,) or (n_samples, n_targets)</span></dt><dd><p>Target values</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>self</strong><span class="classifier">returns an instance of self.</span></dt><dd></dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.get_params">
<code class="sig-name descname">get_params</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">deep=True</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/base.py#L173"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.get_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Get parameters for this estimator.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>deep</strong><span class="classifier">bool, default=True</span></dt><dd><p>If True, will return the parameters for this estimator and
contained subobjects that are estimators.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>params</strong><span class="classifier">mapping of string to any</span></dt><dd><p>Parameter names mapped to their values.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.log_marginal_likelihood">
<code class="sig-name descname">log_marginal_likelihood</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">theta=None</em>, <em class="sig-param">eval_gradient=False</em>, <em class="sig-param">clone_kernel=True</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/gaussian_process/_gpr.py#L407"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.log_marginal_likelihood" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns log-marginal likelihood of theta for training data.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>theta</strong><span class="classifier">array-like of shape (n_kernel_params,) or None</span></dt><dd><p>Kernel hyperparameters for which the log-marginal likelihood is
evaluated. If None, the precomputed log_marginal_likelihood
of <code class="docutils literal notranslate"><span class="pre">self.kernel_.theta</span></code> is returned.</p>
</dd>
<dt><strong>eval_gradient</strong><span class="classifier">bool, default: False</span></dt><dd><p>If True, the gradient of the log-marginal likelihood with respect
to the kernel hyperparameters at position theta is returned
additionally. If True, theta must not be None.</p>
</dd>
<dt><strong>clone_kernel</strong><span class="classifier">bool, default=True</span></dt><dd><p>If True, the kernel attribute is copied. If False, the kernel
attribute is modified, but may result in a performance improvement.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>log_likelihood</strong><span class="classifier">float</span></dt><dd><p>Log-marginal likelihood of theta for training data.</p>
</dd>
<dt><strong>log_likelihood_gradient</strong><span class="classifier">array, shape = (n_kernel_params,), optional</span></dt><dd><p>Gradient of the log-marginal likelihood with respect to the kernel
hyperparameters at position theta.
Only returned when eval_gradient is True.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.predict">
<code class="sig-name descname">predict</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em>, <em class="sig-param">return_std=False</em>, <em class="sig-param">return_cov=False</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/gaussian_process/_gpr.py#L275"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.predict" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict using the Gaussian process regression model</p>
<p>We can also predict based on an unfitted model by using the GP prior.
In addition to the mean of the predictive distribution, also its
standard deviation (return_std=True) or covariance (return_cov=True).
Note that at most one of the two can be requested.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">sequence of length n_samples</span></dt><dd><p>Query points where the GP is evaluated.
Could either be array-like with shape = (n_samples, n_features)
or a list of objects.</p>
</dd>
<dt><strong>return_std</strong><span class="classifier">bool, default: False</span></dt><dd><p>If True, the standard-deviation of the predictive distribution at
the query points is returned along with the mean.</p>
</dd>
<dt><strong>return_cov</strong><span class="classifier">bool, default: False</span></dt><dd><p>If True, the covariance of the joint predictive distribution at
the query points is returned along with the mean</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>y_mean</strong><span class="classifier">array, shape = (n_samples, [n_output_dims])</span></dt><dd><p>Mean of predictive distribution a query points</p>
</dd>
<dt><strong>y_std</strong><span class="classifier">array, shape = (n_samples,), optional</span></dt><dd><p>Standard deviation of predictive distribution at query points.
Only returned when return_std is True.</p>
</dd>
<dt><strong>y_cov</strong><span class="classifier">array, shape = (n_samples, n_samples), optional</span></dt><dd><p>Covariance of joint predictive distribution a query points.
Only returned when return_cov is True.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.sample_y">
<code class="sig-name descname">sample_y</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em>, <em class="sig-param">n_samples=1</em>, <em class="sig-param">random_state=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/gaussian_process/_gpr.py#L369"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.sample_y" title="Permalink to this definition">¶</a></dt>
<dd><p>Draw samples from Gaussian process and evaluate at X.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">sequence of length n_samples</span></dt><dd><p>Query points where the GP is evaluated.
Could either be array-like with shape = (n_samples, n_features)
or a list of objects.</p>
</dd>
<dt><strong>n_samples</strong><span class="classifier">int, default: 1</span></dt><dd><p>The number of samples drawn from the Gaussian process</p>
</dd>
<dt><strong>random_state</strong><span class="classifier">int, RandomState instance or None, optional (default=0)</span></dt><dd><p>If int, random_state is the seed used by the random number
generator; If RandomState instance, random_state is the
random number generator; If None, the random number
generator is the RandomState instance used by <code class="docutils literal notranslate"><span class="pre">np.random</span></code>.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>y_samples</strong><span class="classifier">array, shape = (n_samples_X, [n_output_dims], n_samples)</span></dt><dd><p>Values of n_samples samples drawn from Gaussian process and
evaluated at query points.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.score">
<code class="sig-name descname">score</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em>, <em class="sig-param">y</em>, <em class="sig-param">sample_weight=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/base.py#L376"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.score" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the coefficient of determination R^2 of the prediction.</p>
<p>The coefficient R^2 is defined as (1 - u/v), where u is the residual
sum of squares ((y_true - y_pred) ** 2).sum() and v is the total
sum of squares ((y_true - y_true.mean()) ** 2).sum().
The best possible score is 1.0 and it can be negative (because the
model can be arbitrarily worse). A constant model that always
predicts the expected value of y, disregarding the input features,
would get a R^2 score of 0.0.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">array-like of shape (n_samples, n_features)</span></dt><dd><p>Test samples. For some estimators this may be a
precomputed kernel matrix or a list of generic objects instead,
shape = (n_samples, n_samples_fitted),
where n_samples_fitted is the number of
samples used in the fitting for the estimator.</p>
</dd>
<dt><strong>y</strong><span class="classifier">array-like of shape (n_samples,) or (n_samples, n_outputs)</span></dt><dd><p>True values for X.</p>
</dd>
<dt><strong>sample_weight</strong><span class="classifier">array-like of shape (n_samples,), default=None</span></dt><dd><p>Sample weights.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>score</strong><span class="classifier">float</span></dt><dd><p>R^2 of self.predict(X) wrt. y.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>The R2 score used when calling <code class="docutils literal notranslate"><span class="pre">score</span></code> on a regressor will use
<code class="docutils literal notranslate"><span class="pre">multioutput='uniform_average'</span></code> from version 0.23 to keep consistent
with <a class="reference internal" href="sklearn.metrics.r2_score.html#sklearn.metrics.r2_score" title="sklearn.metrics.r2_score"><code class="xref py py-func docutils literal notranslate"><span class="pre">r2_score</span></code></a>. This will influence the
<code class="docutils literal notranslate"><span class="pre">score</span></code> method of all the multioutput regressors (except for
<a class="reference internal" href="sklearn.multioutput.MultiOutputRegressor.html#sklearn.multioutput.MultiOutputRegressor" title="sklearn.multioutput.MultiOutputRegressor"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiOutputRegressor</span></code></a>). To specify the
default value manually and avoid the warning, please either call
<a class="reference internal" href="sklearn.metrics.r2_score.html#sklearn.metrics.r2_score" title="sklearn.metrics.r2_score"><code class="xref py py-func docutils literal notranslate"><span class="pre">r2_score</span></code></a> directly or make a custom scorer with
<a class="reference internal" href="sklearn.metrics.make_scorer.html#sklearn.metrics.make_scorer" title="sklearn.metrics.make_scorer"><code class="xref py py-func docutils literal notranslate"><span class="pre">make_scorer</span></code></a> (the built-in scorer <code class="docutils literal notranslate"><span class="pre">'r2'</span></code> uses
<code class="docutils literal notranslate"><span class="pre">multioutput='uniform_average'</span></code>).</p>
</dd></dl>

<dl class="method">
<dt id="sklearn.gaussian_process.GaussianProcessRegressor.set_params">
<code class="sig-name descname">set_params</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">**params</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/base.py#L205"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.gaussian_process.GaussianProcessRegressor.set_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the parameters of this estimator.</p>
<p>The method works on simple estimators as well as on nested objects
(such as pipelines). The latter have parameters of the form
<code class="docutils literal notranslate"><span class="pre">&lt;component&gt;__&lt;parameter&gt;</span></code> so that it’s possible to update each
component of a nested object.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>**params</strong><span class="classifier">dict</span></dt><dd><p>Estimator parameters.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>self</strong><span class="classifier">object</span></dt><dd><p>Estimator instance.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

</dd></dl>

<div class="section" id="examples-using-sklearn-gaussian-process-gaussianprocessregressor">
<h2>Examples using <code class="docutils literal notranslate"><span class="pre">sklearn.gaussian_process.GaussianProcessRegressor</span></code><a class="headerlink" href="#examples-using-sklearn-gaussian-process-gaussianprocessregressor" title="Permalink to this headline">¶</a></h2>
<div class="sphx-glr-thumbcontainer" tooltip="Both kernel ridge regression (KRR) and Gaussian process regression (GPR) learn a target functio..."><div class="figure align-default" id="id1">
<img alt="../../_images/sphx_glr_plot_compare_gpr_krr_thumb.png" src="../../_images/sphx_glr_plot_compare_gpr_krr_thumb.png" />
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/gaussian_process/plot_compare_gpr_krr.html#sphx-glr-auto-examples-gaussian-process-plot-compare-gpr-krr-py"><span class="std std-ref">Comparison of kernel ridge and Gaussian process regression</span></a></span><a class="headerlink" href="#id1" title="Permalink to this image">¶</a></p>
</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the prior and posterior of a GPR with different kernels. Mean, standar..."><div class="figure align-default" id="id2">
<img alt="../../_images/sphx_glr_plot_gpr_prior_posterior_thumb.png" src="../../_images/sphx_glr_plot_gpr_prior_posterior_thumb.png" />
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/gaussian_process/plot_gpr_prior_posterior.html#sphx-glr-auto-examples-gaussian-process-plot-gpr-prior-posterior-py"><span class="std std-ref">Illustration of prior and posterior Gaussian process for different kernels</span></a></span><a class="headerlink" href="#id2" title="Permalink to this image">¶</a></p>
</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This example illustrates that GPR with a sum-kernel including a WhiteKernel can estimate the no..."><div class="figure align-default" id="id3">
<img alt="../../_images/sphx_glr_plot_gpr_noisy_thumb.png" src="../../_images/sphx_glr_plot_gpr_noisy_thumb.png" />
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/gaussian_process/plot_gpr_noisy.html#sphx-glr-auto-examples-gaussian-process-plot-gpr-noisy-py"><span class="std std-ref">Gaussian process regression (GPR) with noise-level estimation</span></a></span><a class="headerlink" href="#id3" title="Permalink to this image">¶</a></p>
</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="A simple one-dimensional regression example computed in two different ways:"><div class="figure align-default" id="id4">
<img alt="../../_images/sphx_glr_plot_gpr_noisy_targets_thumb.png" src="../../_images/sphx_glr_plot_gpr_noisy_targets_thumb.png" />
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/gaussian_process/plot_gpr_noisy_targets.html#sphx-glr-auto-examples-gaussian-process-plot-gpr-noisy-targets-py"><span class="std std-ref">Gaussian Processes regression: basic introductory example</span></a></span><a class="headerlink" href="#id4" title="Permalink to this image">¶</a></p>
</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This example is based on Section 5.4.3 of &quot;Gaussian Processes for Machine Learning&quot; [RW2006]. I..."><div class="figure align-default" id="id5">
<img alt="../../_images/sphx_glr_plot_gpr_co2_thumb.png" src="../../_images/sphx_glr_plot_gpr_co2_thumb.png" />
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/gaussian_process/plot_gpr_co2.html#sphx-glr-auto-examples-gaussian-process-plot-gpr-co2-py"><span class="std std-ref">Gaussian process regression (GPR) on Mauna Loa CO2 data.</span></a></span><a class="headerlink" href="#id5" title="Permalink to this image">¶</a></p>
</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the use of Gaussian processes for regression and classification tasks ..."><div class="figure align-default" id="id6">
<img alt="../../_images/sphx_glr_plot_gpr_on_structured_data_thumb.png" src="../../_images/sphx_glr_plot_gpr_on_structured_data_thumb.png" />
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/gaussian_process/plot_gpr_on_structured_data.html#sphx-glr-auto-examples-gaussian-process-plot-gpr-on-structured-data-py"><span class="std std-ref">Gaussian processes on discrete data structures</span></a></span><a class="headerlink" href="#id6" title="Permalink to this image">¶</a></p>
</div>
</div><div class="clearer"></div></div>
</div>


      </div>
    <div class="container">
      <footer class="sk-content-footer">
            &copy; 2007 - 2019, scikit-learn developers (BSD License).
          <a href="../../_sources/modules/generated/sklearn.gaussian_process.GaussianProcessRegressor.rst.txt" rel="nofollow">Show this page source</a>
      </footer>
    </div>
  </div>
</div>
<script src="../../_static/js/vendor/bootstrap.min.js"></script>

<script>
    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
    ga('create', 'UA-22606712-2', 'auto');
    ga('set', 'anonymizeIp', true);
    ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>


<script>
$(document).ready(function() {
    /* Add a [>>>] button on the top-right corner of code samples to hide
     * the >>> and ... prompts and the output and thus make the code
     * copyable. */
    var div = $('.highlight-python .highlight,' +
                '.highlight-python3 .highlight,' +
                '.highlight-pycon .highlight,' +
		'.highlight-default .highlight')
    var pre = div.find('pre');

    // get the styles from the current theme
    pre.parent().parent().css('position', 'relative');
    var hide_text = 'Hide prompts and outputs';
    var show_text = 'Show prompts and outputs';

    // create and add the button to all the code blocks that contain >>>
    div.each(function(index) {
        var jthis = $(this);
        if (jthis.find('.gp').length > 0) {
            var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
            jthis.prepend(button);
        }
        // tracebacks (.gt) contain bare text elements that need to be
        // wrapped in a span to work with .nextUntil() (see later)
        jthis.find('pre:has(.gt)').contents().filter(function() {
            return ((this.nodeType == 3) && (this.data.trim().length > 0));
        }).wrap('<span>');
    });

    // define the behavior of the button when it's clicked
    $('.copybutton').click(function(e){
        e.preventDefault();
        var button = $(this);
        if (button.data('hidden') === 'false') {
            // hide the code output
            button.parent().find('.go, .gp, .gt').hide();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
            button.css('text-decoration', 'line-through');
            button.attr('title', show_text);
            button.data('hidden', 'true');
        } else {
            // show the code output
            button.parent().find('.go, .gp, .gt').show();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
            button.css('text-decoration', 'none');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
        }
    });

	/*** Add permalink buttons next to glossary terms ***/
	$('dl.glossary > dt[id]').append(function() {
		return ('<a class="headerlink" href="#' +
			    this.getAttribute('id') +
			    '" title="Permalink to this term">¶</a>');
	});
  /*** Hide navbar when scrolling down ***/
  // Returns true when headerlink target matches hash in url
  (function() {
    hashTargetOnTop = function() {
        var hash = window.location.hash;
        if ( hash.length < 2 ) { return false; }

        var target = document.getElementById( hash.slice(1) );
        if ( target === null ) { return false; }

        var top = target.getBoundingClientRect().top;
        return (top < 2) && (top > -2);
    };

    // Hide navbar on load if hash target is on top
    var navBar = document.getElementById("navbar");
    var navBarToggler = document.getElementById("sk-navbar-toggler");
    var navBarHeightHidden = "-" + navBar.getBoundingClientRect().height + "px";
    var $window = $(window);

    hideNavBar = function() {
        navBar.style.top = navBarHeightHidden;
    };

    showNavBar = function() {
        navBar.style.top = "0";
    }

    if (hashTargetOnTop()) {
        hideNavBar()
    }

    var prevScrollpos = window.pageYOffset;
    hideOnScroll = function(lastScrollTop) {
        if (($window.width() < 768) && (navBarToggler.getAttribute("aria-expanded") === 'true')) {
            return;
        }
        if (lastScrollTop > 2 && (prevScrollpos <= lastScrollTop) || hashTargetOnTop()){
            hideNavBar()
        } else {
            showNavBar()
        }
        prevScrollpos = lastScrollTop;
    };

    /*** high preformance scroll event listener***/
    var raf = window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        window.oRequestAnimationFrame;
    var lastScrollTop = $window.scrollTop();

    if (raf) {
        loop();
    }

    function loop() {
        var scrollTop = $window.scrollTop();
        if (lastScrollTop === scrollTop) {
            raf(loop);
            return;
        } else {
            lastScrollTop = scrollTop;
            hideOnScroll(lastScrollTop);
            raf(loop);
        }
    }
  })();
});

</script>
    
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
    
</body>
</html>